数组中的最大值
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//数组[1，2，5，10，12，8，20]数组中的最大值
			//标杆
			var nums = [1,2,5,10,12,8,20]
			var max = nums[0]
			//遍历
			for(var i=0;i<nums.length;i++){
				if(max<nums[i]){
				max = nums[i]
				}
			}
			console.log(max)
		</script>
	</body>
</html>

数组中的最小值
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//数组[1，2，5，10，12，8，20]数组中的最小值
			//标杆
			var nums = [1,2,5,10,12,8,20]
			var min = nums[0]
			//遍历
			for(var i=0;i<nums.length;i++){
				if(min>nums[i]){
				min = nums[i]
				}
			}
			console.log(min)
		</script>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var ass = ['red','green','blue','pink']
			var bss = ass[0]
			var pss = '|'
			for(var i=1;i<ass.length;i++){
				//
				bss += pss + ass[i]
			}
			console.log(bss)
		</script>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			// 1、数组的长度变长，但是并没有赋值
			var arr1 = [1,2]
			//修改长度
			arr1.length = 4
			console.log(arr1)
			//2、数组创建的时候
			//2.1字面量创建时，出现空位置
			var arr2 = [1,2,,4]
			console.log(arr2)
			//2.2使用new Array方式创建
			var arr3 = new Array(3)
			console.log(arr3.length)
			console.log(arr3)
			//3、数组增长 ，下标出现不连续
			var arr4 = [1,2]
			arr4[3]=4
			console.log(arr4)
			//所有的空位置取值都是undefined
			console.log(arr4[2])
		</script>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var arr=[2,0,6,1,77,0,52,0,25,7]
			var newArr=[]
			var j= 0
			for(var i=0;i<arr.length;i++){
				if(arr[i]>=10){
					newArr[j++]=arr[i]
				}
			}
			console.log(newArr)
		</script>
	</body>
</html>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//筛选数组元素
			var arr=[2,0,6,1,77,0,52,0,25,7]
			var newArr=[]
			var j= 0
			for(var i=0;i<arr.length;i++){
				if(arr[i]>=10){
//					newArr[j]=arr[i]
//					j++
                newArr[j++]=arr[i]
				}
			}
			console.log(newArr)
		</script>
	</body>
</html>

删除数组的指定元素
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var arr = [2,0,6,1,77,0,52,0,25,7]
			var newArr = []
			for(var i=0;i<arr.length;i++){
				if(arr[i]!=0){
					newArr[newArr.length] = arr[i]
				}
			}
			console.log(newArr)
		</script>
	</body>
</html>

数组反转
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var arr = ['red','green','blue','pink','purple']
			newArr = []
			for(var i=arr.length-1;i>=0;i--){
				newArr[newArr.length] = arr[i]
			}
			console.log(newArr)
		</script>
	</body>
</html>

冒泡排序
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var arr = [10,7,5,27,98,31]
			for(var i=0;i<arr.length-1;i++){
				if(arr[i]>arr[i+1]){
					var temp = arr[i]
					arr[i] = arr[i+1]
					arr[i+1]=temp
				}
			}
			console.log(arr)
		</script>
	</body>
</html>
